﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using ItemStatistics.Models;


namespace ItemStatistics.ViewModels.GiftVMs
{
    public partial class GiftListVM : BasePagedListVM<Gift_View, GiftSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("Gift", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"", dialogWidth: 800),
                this.MakeStandardAction("Gift", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "", dialogWidth: 800),
               // this.MakeStandardAction("Gift", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "", dialogWidth: 800),
                //this.MakeStandardAction("Gift", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "", dialogWidth: 800),
                //this.MakeStandardAction("Gift", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "", dialogWidth: 800),
                this.MakeStandardAction("Gift", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "", dialogWidth: 800),
                this.MakeStandardAction("Gift", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "", dialogWidth: 800),
                //this.MakeStandardAction("Gift", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], ""),
            };
        }


        protected override IEnumerable<IGridColumn<Gift_View>> InitGridHeader()
        {
            return new List<GridColumn<Gift_View>>{
                this.MakeGridHeader(x => x.Name,110),
                this.MakeGridHeader(x => x.Description,90),
                this.MakeGridHeaderAction(width: 80)
            };
        }

        public override IOrderedQueryable<Gift_View> GetSearchQuery()
        {
            var query = DC.Set<Gift>()
                .CheckContain(Searcher.Name, x=>x.Name)
                .Select(x => new Gift_View
                {
				    ID = x.ID,
                    Name = x.Name,
                    Description = x.Description,
                })
                .OrderBy(x => x.Name);
            return query;
        }

    }

    public class Gift_View : Gift{

    }
}
